package cz.ctu.guiproject.client.formvalidation;

import android.view.View;
import android.view.View.OnFocusChangeListener;
import android.widget.EditText;

public abstract class TextValidator implements OnFocusChangeListener {
	private final EditText editText;

	public TextValidator(EditText editText) {
		this.editText = editText;
	}

	abstract public boolean validate(EditText editText);
	
	@Override
	public final void onFocusChange(View v, boolean hasFocus) {
		if (!hasFocus) {
			validate(editText);
		}
	}
}
